//
//  CustomView.m
//  UI05_delegate设计模式实现view点击事件回调
//
//  Created by Scott on 16/5/9.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "CustomView.h"

@implementation CustomView

#pragma mark - override Touch
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [super touchesEnded:touches withEvent:event];
    
    // 适当时机让delegate 调用协议方法.
    if ([self.delegate respondsToSelector:@selector(customViewDidClick:)]) {
        
        [self.delegate customViewDidClick:self];
        
    }

}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    
    [super touchesBegan:touches withEvent:event];
    
    
    if ([self.delegate respondsToSelector:@selector(customViewShouldClick:)]) {
        
        [self.delegate customViewShouldClick:self];
    }
    
    
}










@end
